package com.jr9z.jrjz.service.impl;

import com.jr9z.jrjz.dao.NewsMapper;
import com.jr9z.jrjz.entity.News;
import com.jr9z.jrjz.service.NewsService;
import com.jr9z.jrjz.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:Mrzhang
 * @Description:
 * @Date:2019.03.25 21:55
 **/

@Service
public class NewsServiceImpl implements NewsService {

    @Autowired
    private NewsMapper newsMapper;

    @Override
    public int deleteByPrimaryKey(Integer newsId) {
        return newsMapper.deleteByPrimaryKey(newsId);
    }

    @Override
    public int insert(News record) {
        return newsMapper.insert(record);
    }

    @Override
    public int insertSelective(News record) {

        if (record != null) {
            record.setCreateTime(DateUtils.getNowDateString());
        }
        return newsMapper.insertSelective(record);
    }

    @Override
    public News selectByPrimaryKey(Integer newsId) {
        return newsMapper.selectByPrimaryKey(newsId);
    }

    @Override
    public int updateByPrimaryKeySelective(News record) {
        return newsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKeyWithBLOBs(News record) {
        return newsMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(News record) {
        return newsMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<News> getNewsTypeOne() {
        return newsMapper.getNewsTypeOne();
    }

    @Override
    public List<News> getNewsTypeTwo() {
        return newsMapper.getNewsTypeTwo();
    }

    @Override
    public Long getCountTypeOne() {
        return newsMapper.getCountTypeOne();
    }

    @Override
    public Long getCountTypeTwo() {
        return newsMapper.getCountTypeTwo();
    }

    @Override
    public List<News> getAllNews() {
        return newsMapper.getAllNews();
    }

    @Override
    public Long getCountAll() {
        return newsMapper.getCountAll();
    }

    @Override
    public News getPrevNews(Integer newsId) {
        return newsMapper.getPrevNews(newsId);
    }

    @Override
    public News getNextNews(Integer newsId) {
        return newsMapper.getNextNews(newsId);
    }
}
